reward=".50",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=qualReqs
)
# Get HITId (record result below)
newHIT$HITId
# "2C2CJ011K274LPOO4SX1EN488TRCAG"
HITStatus(hit="2C2CJ011K274LPOO4SX1EN488TRCAG")
qualReqs = paste(
# Set Location to US only
GenerateQualificationRequirement(
"Location","==","US"),
# Worker_PercentAssignmentsApproved
GenerateQualificationRequirement(
"000000000000000000L0", ">", "80",
qual.number=2),
# Un-comment after sandbox test
# Worker_NumberHITsApproved
# GenerateQualificationRequirement(
#   "00000000000000000040", ">", "100",
#   qual.number=3),
sep="" )
qualReqs
qualReqs = paste(
# Set Location to US only
GenerateQualificationRequirement(
"Location","==","US"))
qualReqs
?CreateHIT
a <- ListQualificationTypes()
View(a)
q1 <- GenerateQualificationRequirement(a[2,2],">","90")
rm(list=ls())
# install.packages("devtools")
library(devtools)
install_github(repo="MTurkR",
username = "leeper")
require("MTurkR")
credentials(c("AKIAJIMUZXUID6VWA64Q","4XG5v9/qnzGbTY8yzcxm67Uzvfyu2srt+Ootng9Z"))
AccountBalance()
#install.packages("MTurkRGUI")
library("MTurkRGUI")
#layout
#321KFBXXMMG2G7QTGPLRYTM7YUHPJ2
# First set qualifications
# ListQualificationTypes() to see different qual types
qualReqs = paste(
# Set Location to US only
GenerateQualificationRequirement(
"Location","==","US"),
# Worker_PercentAssignmentsApproved
GenerateQualificationRequirement(
"000000000000000000L0", ">", "80",
qual.number=2),
# Un-comment after sandbox test
# Worker_NumberHITsApproved
# GenerateQualificationRequirement(
#   "00000000000000000040", ">", "100",
#   qual.number=3),
sep="" )
a <- ListQualificationTypes()
q1 <- GenerateQualificationRequirement(a[2,2],">","90")
# Create new batch of hits:
newHIT = CreateHIT(
# layoutid in sandbox:
hitlayoutid="321KFBXXMMG2G7QTGPLRYTM7YUHPJ2",
sandbox=T,
# layoutid in production:
# hitlayoutid="2C9X7H57DZKPHWJIU98DS25L8N41BW",
annotation = "HET Experiment with Pre-Screen",
assignments = "1200",
title="Rate this hypothetical representative",
description="It's easy, just rate this
hypothetical representative on how well
she delivers funds to his district",
reward=".50",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=q1
)
View(a)
q1 <- GenerateQualificationRequirement(a[2,2],">","90")
q2 <- GenerateQualificationRequirement(c("Locale","Approved"),
c("==",">"),
c("US",90),
preview = TRUE)
# Create new batch of hits:
newHIT = CreateHIT(
# layoutid in sandbox:
hitlayoutid="321KFBXXMMG2G7QTGPLRYTM7YUHPJ2",
sandbox=T,
# layoutid in production:
# hitlayoutid="2C9X7H57DZKPHWJIU98DS25L8N41BW",
annotation = "HET Experiment with Pre-Screen",
assignments = "1200",
title="Rate this hypothetical representative",
description="It's easy, just rate this
hypothetical representative on how well
she delivers funds to his district",
reward=".50",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=q2
)
newHIT$HITId
library("MTurkRGUI")
wizard()
qualReqs = paste(
# Set Location to US only
GenerateQualificationRequirement(
"Location","==","US"),
# Worker_PercentAssignmentsApproved
GenerateQualificationRequirement(
"000000000000000000L0", ">", "80",
qual.number=2),
# Un-comment after sandbox test
# Worker_NumberHITsApproved
# GenerateQualificationRequirement(
#   "00000000000000000040", ">", "100",
#   qual.number=3),
sep="" )
newHIT = CreateHIT(
# layoutid in sandbox:
hitlayoutid="321KFBXXMMG2G7QTGPLRYTM7YUHPJ2",
sandbox=T,
# layoutid in production:
# hitlayoutid="2C9X7H57DZKPHWJIU98DS25L8N41BW",
annotation = "HET Experiment with Pre-Screen",
assignments = "1200",
title="Rate this hypothetical representative",
description="It's easy, just rate this
hypothetical representative on how well
she delivers funds to his district",
reward=".50",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=qualReqs
)
q_names <- c("Locale", "NumberApproved")
# Comparators ("==" for location and ">" for past approvals)
q_comparators <- c("==", ">")
# Qualification values ("US" for location and "500" for past approvals)
q_values <- c("US", 500)
# Convert these values into a QualificationRequirement
qreq2 <- GenerateQualificationRequirement(q_names,
q_comparators,
q_values,
preview = TRUE)
# Create new batch of hits:
newHIT = CreateHIT(
# layoutid in sandbox:
hitlayoutid="321KFBXXMMG2G7QTGPLRYTM7YUHPJ2",
sandbox=T,
# layoutid in production:
# hitlayoutid="2C9X7H57DZKPHWJIU98DS25L8N41BW",
annotation = "HET Experiment with Pre-Screen",
assignments = "1200",
title="Rate this hypothetical representative",
description="It's easy, just rate this
hypothetical representative on how well
she delivers funds to his district",
reward=".50",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=qreq2
)
?CreateHIT
# Create new batch of hits:
newHIT = CreateHIT(
# layoutid in sandbox:
hitlayoutid="321KFBXXMMG2G7QTGPLRYTM7YUHPJ2",
sandbox=F,
# layoutid in production:
# hitlayoutid="2C9X7H57DZKPHWJIU98DS25L8N41BW",
annotation = "HET Experiment with Pre-Screen",
assignments = "1200",
title="Rate this hypothetical representative",
description="It's easy, just rate this
hypothetical representative on how well
she delivers funds to his district",
reward=".00",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=qreq2
)
# Create new batch of hits:
newHIT = CreateHIT(
# layoutid in sandbox:
hitlayoutid="321KFBXXMMG2G7QTGPLRYTM7YUHPJ2",
sandbox=T,
# layoutid in production:
# hitlayoutid="2C9X7H57DZKPHWJIU98DS25L8N41BW",
annotation = "HET Experiment with Pre-Screen",
assignments = "1200",
title="Rate this hypothetical representative",
description="It's easy, just rate this
hypothetical representative on how well
she delivers funds to his district",
reward=".50",
duration=seconds(hours=4),
expiration=seconds(days=7),
keywords="survey, question, answers, research,
politics, opinion",
auto.approval.delay=seconds(days=15),
qual.reqs=GenerateQualificationRequirement
("Location","==","US",preview=TRUE)
)
wizard.simple()
rm(list=ls())
# install.packages("devtools")
library(devtools)
install_github(repo="MTurkR",
username = "leeper")
require("MTurkR")
credentials(c("AKIAJIMUZXUID6VWA64Q","4XG5v9/qnzGbTY8yzcxm67Uzvfyu2srt+Ootng9Z"))
AccountBalance()
#install.packages("MTurkRGUI")
library("MTurkRGUI")
library("MTurkRGUI")
#wizard()
rm(list=ls())
# install.packages("devtools")
library(devtools)
install_github(repo="MTurkR",
username = "leeper")
require("MTurkR")
install.packages("MTurkR")
install.packages("MTurkR")
library(MTurkR)
credentials(c("AKIAJIMUZXUID6VWA64Q","4XG5v9/qnzGbTY8yzcxm67Uzvfyu2srt+Ootng9Z"))
library("MTurkRGUI")
credentials(c("AKIAJIMUZXUID6VWA64Q","4XG5v9/qnzGbTY8yzcxm67Uzvfyu2srt+Ootng9Z"))
wizard.simple()
1
wizard.simple()
wizard()
library("MTurkRGUI")
wizard(style = "tcltk", sandbox = T)
wizard()
library("MTurkRGUI")
wizard()
wizard.simple()
install.packages("utils")
install.packages("utils")
install.packages("utils")
install.packages("utils")
install.packages("utils")
install.packages("utils")
install.packages("rgdal")
install.packages("sp")
install.packages("raster")
install.packages("maptools")
install.packages("readxl")
install.packages("dismo")
install.packages(rvest)
install.packages("rvest")
library(rvest)
lego_movie <- html("http://www.imdb.com/title/tt1490017/")
lego_movie <- read_html("http://www.imdb.com/title/tt1490017/")
newHIT$HITId
?ForceExpireHIT
ExpireHIT(annotation = "Age Discontinuity")
###### Age Discontinuity Project #####
rm(list=ls())
#install.packages("MTurkR")
library(MTurkR)
ExpireHIT(annotation = "Age Discontinuity")
#### HIT Layout ID
my_hitlayoutid = "3ASV3OFR42CJMZI2XGVXUQM97U5DYQ"
box_hitlayoutid = "3L4W8HTQ7W6754MBG8KJMU65MPZY8W"
#### Set MTurk credentials
Sys.setenv(
AWS_ACCESS_KEY_ID = "AKIAJIMUZXUID6VWA64Q",
AWS_SECRET_ACCESS_KEY = "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"
)
AccountBalance()
#### HIT parameters
## Run in sandbox?
sandbox_val <- "FALSE"
ExpireHIT(annotation = "Age Discontinuity")
GetAssignments(hit = "3WPCIUYH1A84OI63IFNU3LWUEQ3DT4")
data = GetAssignments(hit = "3WPCIUYH1A84OI63IFNU3LWUEQ3DT4")
View(data)
data = GetAssignments(hit = "3WPCIUYH1A84OI63IFNU3LWUEQ3DT4")
###### Age Discontinuity Project #####
rm(list=ls())
#install.packages("MTurkR")
library(MTurkR)
##### Notes:
# 1) Change sandbox from TRUE to FALSE to run live (make sure to test in sandbox first!!)
#### Load library, set parameters
#### Load MTurkR library
library(MTurkR)
#### HIT Layout ID
my_hitlayoutid = "3ASV3OFR42CJMZI2XGVXUQM97U5DYQ"
box_hitlayoutid = "3L4W8HTQ7W6754MBG8KJMU65MPZY8W"
#### Set MTurk credentials
Sys.setenv(
AWS_ACCESS_KEY_ID = "AKIAJIMUZXUID6VWA64Q",
AWS_SECRET_ACCESS_KEY = "4XG5v9/qnzGbTY8yzcxm67Uzvfyu2srt+Ootng9Z"
)
AccountBalance()
#### HIT parameters
## Run in sandbox?
sandbox_val <- "FALSE"
## Set the name of your project here (used to retrieve HITs later)
myannotation <- "Age Discontinuity"
# Shorthand names of location and approval qualifications
q_names <- c("Worker_Locale", "Worker_NumberHITsApproved", "Worker_PercentAssignmentsApproved")
qn2 <- c("00000000000000000071", "00000000000000000040", "000000000000000000L0")
# Comparators ("==" for location and ">" for past approvals)
q_comparators <- c("==", ">", ">")
# Qualification values ("US" for location and "500" for past approvals)
q_values <- c("US", 50, 90)
# Convert these values into a QualificationRequirement
qreq2 <- GenerateQualificationRequirement(qn2,
q_comparators,
q_values,
preview = TRUE)
## Enter other HIT aspects
newhittype <- RegisterHITType(
title = "Short opinion and knowledge survey on healthcare",
description = "Give us your opinion and test your knowledge on healthcare in the U.S. with bonus opportunity",
reward = "0.20",
duration = seconds(hours = 1),
keywords = "survey, opinion, healthcare, short, bonus",
sandbox = sandbox_val,
qual.req = qreq2
)
newHIT = CreateHIT(
# layoutid in sandbox:
#hitlayoutid= "3L4W8HTQ7W6754MBG8KJMU65MPZY8W",
# layout id for real
hitlayoutid= "3YF8GR2KNPX298JPQXEVRCU6ITZA7M",
annotation = "Age Discontinuity",
assignments = "200",
hit.type = newhittype$HITTypeId,
expiration=seconds(days=3),
auto.approval.delay=seconds(days=3),
)
newHIT$HITId
data = GetAssignments(hit = newHIT$HITId)
###### Age Discontinuity Project #####
rm(list=ls())
#install.packages("MTurkR")
library(MTurkR)
##### Notes:
# 1) Change sandbox from TRUE to FALSE to run live (make sure to test in sandbox first!!)
#### Load library, set parameters
#### Load MTurkR library
library(MTurkR)
#### HIT Layout ID
my_hitlayoutid = "3ASV3OFR42CJMZI2XGVXUQM97U5DYQ"
box_hitlayoutid = "3L4W8HTQ7W6754MBG8KJMU65MPZY8W"
#### Set MTurk credentials
Sys.setenv(
AWS_ACCESS_KEY_ID = "AKIAJIMUZXUID6VWA64Q",
AWS_SECRET_ACCESS_KEY = "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"
)
AccountBalance()
#### HI
data = GetAssignments(hit = newHIT$HITId)
## Run in sandbox?
sandbox_val <- "FALSE"
## Set the name of your project here (used to retrieve HITs later)
myannotation <- "Age Discontinuity"
# Shorthand names of location and approval qualifications
q_names <- c("Worker_Locale", "Worker_NumberHITsApproved", "Worker_PercentAssignmentsApproved")
qn2 <- c("00000000000000000071", "00000000000000000040", "000000000000000000L0")
# Comparators ("==" for location and ">" for past approvals)
q_comparators <- c("==", ">", ">")
# Qualification values ("US" for location and "500" for past approvals)
q_values <- c("US", 50, 90)
# Convert these values into a QualificationRequirement
qreq2 <- GenerateQualificationRequirement(qn2,
q_comparators,
q_values,
preview = TRUE)
## Enter other HIT aspects
newhittype <- RegisterHITType(
title = "Short opinion and knowledge survey on healthcare",
description = "Give us your opinion and test your knowledge on healthcare in the U.S. with bonus opportunity",
reward = "0.20",
duration = seconds(hours = 1),
keywords = "survey, opinion, healthcare, short, bonus",
sandbox = sandbox_val,
qual.req = qreq2
)
data = GetAssignments(annotation = "Age Discontinuity")
View(data)
data = GetAssignments(annotation = "Age Discontinuity", status = "Submitted", return.all = T)
data = GetAssignments(hitID = "3ICOHX7ENCB80FNCG8A4PSCAHRDE0S", status = "Submitted", return.all = T)
data = GetAssignments(hit = "3ICOHX7ENCB80FNCG8A4PSCAHRDE0S", status = "Submitted", return.all = T)
?GrantBonus
bonus.data = data
bonus_str = paste(bonus.data$workerId, collapse = ",")
bonus_str
bonus.data$workerId
bonus_str = paste(bonus.data$WorkerId, collapse = ",")
?GrantBonus
bonus_str
AccountBalance()
ApproveAssignments(assignments = data$AssignmentId, hit = "3ICOHX7ENCB80FNCG8A4PSCAHRDE0S")
AccountBalance()
AccountBalance()
ApproveAssignments(assignments = data$AssignmentId)
AccountBalance()
AccountBalance()
AccountBalance()
AccountBalance()
AccountBalance()
AccountBalance()
bonus.data = data
bonus = GrantBonus(workers = bonus.data$WorkerId, assignments = bonus.data$AssignmentId,
amounts = .1, reasons = "thanks for the good work!")
AccountBalance()
###### Pilot Take 3 of Age Discontinuity in Mturk #####
rm(list=ls())
#install.packages("MTurkR")
library(MTurkR)
library(MTurkR)
#### HIT Layout ID
my_hitlayoutid = "3NH4KOTE61AGYSBYUG4HBQIQECXGFA"
box_hitlayoutid = "3V21LYOO6XY5QL16OZGQ2W8THC2A4T"
#### Set MTurk credentials
Sys.setenv(
AWS_ACCESS_KEY_ID = "AKIAJIMUZXUID6VWA64Q",
AWS_SECRET_ACCESS_KEY = "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"
)
AccountBalance()
data = GetAssignments(hit = 3FI30CQHVKJ57NX786OVXLGGR3W6B7, status = "Submitted", return.all = T)
data = GetAssignments(hit = "3FI30CQHVKJ57NX786OVXLGGR3W6B7", status = "Submitted", return.all = T)
#########################################
### PRODUCING FIGURES FROM EXPERIMENT ###
#########################################
rm(list=ls())
setwd("/Users/samtrachtman/Dropbox/ACA Study/Projects/Public Private Field Experiment/APSR Production/replication materials/submission_data/experiment/")
library(foreign)
library(lmtest)
library(sandwich)
library(plyr)
library(readstata13)
joint.data = read.dta13("dig_ph_append.dta")
#functions for balance plots
check = function(x, tr){
r=rep(NA,3)
r[1] = mean(x[tr==1], na.rm=TRUE)
r[2] = mean(x[tr==0], na.rm=TRUE)
r[3]=t.test(x[tr==1], x[tr==0], na.rm=T)$p.value
return(r)
}
plot.pval <- function(results, title=NULL, legend,legendx=0.15,legendy=2.2, textsize=0.9, parcex=0.8, at1=-0.35, at2=-0.15, at3=-0.9,xlim1=-0.85) {
# set values of different parameters
xlim = c(xlim1,1); pchset = c(21,24,22,23); pchcolset = c("blue","yellow","red","darkgreen")
# set margins and letter size
par(cex=parcex, mai = c(0.5, 0.35, 1.1, 0.35))
# set number of rows
ny = nrow(results)
# create the empty figure
if(!is.null(title))  plot(x=NULL,axes=F, xlim=xlim, ylim=c(1,ny),xlab="",ylab="", main=title)
if(is.null(title))   plot(x=NULL,axes=F, xlim=xlim, ylim=c(1,ny),xlab="",ylab="")
# add the 0, 0.05 and 0.1 vertical lines
abline(v=c(0,0.05,0.1),lty=c(1,4,4), lwd=c(1,2,2))
axis(side=1,at=c(0,0.05,0.1,1),tick=TRUE, las=2, cex.axis=0.7)
# add labels on top of the three areas of the graph
axis(side=3,at=at1,labels="Mean\n.gov",tick=FALSE, padj=0.5,cex.axis=textsize)
axis(side=3,at=at2,labels="Mean\nsherpa",tick=FALSE, padj=0.5,cex.axis=textsize)
axis(side=3,at=0.5,labels="P-values",tick=FALSE, padj=0.5,cex.axis=textsize)
# Fill the figure with the information which is inside the 'results' matrix
# First, add the p-values as points
for(i in 4:ncol(results)) points(results[,i],ny:1, pch = pchset[i-4+1], col = pchcolset[i-4+1], bg = pchcolset[i-4+1])
# Second, add each variable name and the means for treated and control
for(i in 1:ny) {
text(at3,ny-i+1,results[i,1],adj = 0,cex=textsize) # variable name
text(at1,ny-i+1,results[i,2], cex=textsize)        # treatment mean
text(at2,ny-i+1,results[i,3], cex=textsize)        # control mean
}
# Add dotted horizontal lines every two variables to make it prettier
for(i in seq(2,by=2,length.out=floor((ny-1)/2))) abline(h = i+0.5, lty = 3)
# Add legend
#if(legend) legend(x=legendx, y=legendy, c("t-test"), pch=pchset, pt.bg = pchcolset, cex=0.8)
}
#setwd("/Users/samtrachtman/Dropbox/ACA Study/Projects/Public Private Field Experiment/APSR Production/submission_results/experiment/")
varnames = c("College", "White", "Gender","Age","Income", "Party", "Government waste", "Government regulation")
X = cbind(joint.data$college, joint.data$white,joint.data$gender1,joint.data$age2,joint.data$income, joint.data$party3, joint.data$pro_gov, joint.data$pro_reg)
tr = joint.data$tr_gov
tab=t(apply(X,2,check, tr=tr))
options(scipen=2)
tab = round(tab, 2)
tab = cbind(varnames, tab)
tiff(filename = "figureA6.tif")
plot.pval(results=tab, title="Balance Across Treatment and Control", legend=TRUE,legendx=0.15,legendy=2.5, textsize=0.9, parcex=0.8, at1=-0.35, at2=-0.15, at3=-0.9,xlim1=-0.85)
dev.off()
